import React from 'react'
import Child from './Child'
import './index.less'
import {Button} from "antd";
// import 'antd/dist/antd.css'


export default class Life extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0
        }
    }


    //普通函数和箭头函数this指向问题

    add = () => {
        this.setState({count: this.state.count + 1})
    }

    addClick() {
        this.setState({count: this.state.count + 1})
    }

    render() {
        return (
            <div className="content">
                <p>react生命周期</p>
                <Button type="primary" onClick={this.add}>antd 点击一下</Button>
                <button onClick={this.add}>click</button>
                <button onClick={this.addClick.bind(this)}>click</button>
                <p>{this.state.count}</p>
                <Child name={this.state.count}></Child>

            </div>

        )
    }


}   
